Module WebmasterTools::CoreExtensions::Array
In: lib/webmaster_tools/core_ext.rb

Methods

Public Instance methods

Loops through every element in an array and calls "to_sitemap_node.to_xml"

[Source]

    # File lib/webmaster_tools/core_ext.rb, line 6
 6:       def to_sitemap(options = {})
 7:         
 8:         options[:host]
 9:         options[:protocol]
10:         
11:         raise "Not all elements respond to to_sitemap_node" unless all? { |e| e.respond_to? :to_sitemap_node }
12: 
13:         options[:indent]   ||= 2
14:         options[:builder]  ||= Builder::XmlMarkup.new(:indent => options[:indent])
15: 
16:         root     = "urlset"
17:         children = "url"
18: 
19:         options[:builder].instruct! unless options.delete(:skip_instruct)
20: 
21:         opts = options.merge({ :root => children })
22: 
23:         xml = options[:builder]
24:         if empty?
25:           xml.tag!(root, {:xmlns => "http://www.sitemaps.org/schemas/sitemap/0.9"})
26:         else
27:           xml.tag!(root, {:xmlns => "http://www.sitemaps.org/schemas/sitemap/0.9"}) {
28:             yield xml if block_given?
29:             each { |e| e.to_sitemap_node.to_xml(opts.merge!({ :skip_instruct => true })) }
30:           }
31:         end
32:       end

Loops through every element in an array and calls "to_sitemap_index"

[Source]

    # File lib/webmaster_tools/core_ext.rb, line 35
35:       def to_sitemap_index(options = {})
36:         
37:         options[:host]
38:         options[:protocol]
39:         
40:         raise "Not all elements respond to to_sitemap_index_node" unless all? { |e| e.respond_to? :to_sitemap_index_node }
41: 
42:         options[:indent]   ||= 2
43:         options[:builder]  ||= Builder::XmlMarkup.new(:indent => options[:indent])
44: 
45:         root     = "sitemapindex"
46:         children = "sitemap"
47: 
48:         options[:builder].instruct! unless options.delete(:skip_instruct)
49: 
50:         opts = options.merge({ :root => children })
51: 
52:         xml = options[:builder]
53:         if empty?
54:           xml.tag!(root, {:xmlns => "http://www.sitemaps.org/schemas/sitemap/0.9"})
55:         else
56:           xml.tag!(root, {:xmlns => "http://www.sitemaps.org/schemas/sitemap/0.9"}) {
57:             yield xml if block_given?
58:             each { |e| e.to_sitemap_index_node.to_xml(opts.merge!({ :skip_instruct => true })) }
59:           }
60:         end
61:       end

[Validate]